fn main() {
    println!("{}", call_repeat(add_one, 30));

    let num = [1, 2, 3];
    // let num_to_str: Vec<String> = num.iter().map(|val| val.to_string()).collect();
    let num_to_str: Vec<String> = num.iter().map(ToString::to_string).collect();

    println!("{:?}", num_to_str);

    let list_of_age: Vec<Age> = (5u32..20).map(Age).collect();

    println!("{:?}", list_of_age);

    println!("{}", returns_closure()(3));

    let num = vec![1, 2, 3];

    Info::print();
}

fn add_one(val: i32) -> i32 {
    val + 1
}
fn call_repeat(add: fn(i32) -> i32, target: i32) -> i32 {
    add(target) + add(target)
}

#[derive(Debug)]
struct Age(u32);

// fn returns_closure() -> Box<dyn Fn(i32) -> i32> {
//     Box::new(|val| val + 1)
// }

fn returns_closure() -> impl Fn(i32) -> i32 {
    |val| val + 1
}

#[macro_export]
macro_rules! Vec {
    ($($x:expr),*) => {
        {
            let mut temp_vec = Vec::new();
            $(
                temp_vec.push($x);
            )*
            temp_vec
        }
    };
}

trait Log {
    fn print();
}

struct Info;

impl Log for Info {
    fn print() {
        println!("log-info");
    }
}
